package com.bjpowernode.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@Controller
public class UserController {

    @RequestMapping(value = "/user/json/detail")
    @ResponseBody
    public Object userJsonDetail(){

        Map<String,Object> map = new HashMap<>();
        map.put("id",1);
        map.put("userName","lisi");
        return map;
    }

    /*@RequestMapping(value = "/user/page/detail")
    public String userPageDetail(Model model){
        model.addAttribute("id",2);
        model.addAttribute("userName","wangwu");

        return "userDetail";
    }*/

    @RequestMapping(value = "/user/page/detail")
    @ResponseBody
    public ModelAndView  userPageDetail(){
        ModelAndView modelAndView = new ModelAndView();

        modelAndView.addObject("id",1002);
        modelAndView.addObject("userName","theSun");

        modelAndView.setViewName("userDetail");
        return modelAndView;
    }
}
